/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.apt.hanhhanh.matrimony.methods;

import java.sql.Array;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apt.matrimony.beans.AccountBasicBean;
import org.apt.matrimony.beans.AccountDetailBeans;
import org.apt.matrimony.beans.CasteBeans;
import org.apt.matrimony.beans.CityBeans;
import org.apt.matrimony.beans.CountryBeans;
import org.apt.matrimony.beans.LikingCateBeans;
import org.apt.matrimony.beans.LikingModelBeans;
import org.apt.matrimony.beans.MotherTongueBeans;
import org.apt.matrimony.beans.ProfessionalBeans;
import org.apt.matrimony.beans.ReligionBeans;
import org.apt.matrimony.beans.RequestBeans;
import org.apt.matrimony.db.MyConnection;

/**
 *
 * @author HanhHanh
 */
public class selects {

    public static List<LikingModelBeans> getLikingModelBylikingCate(String likingCate) {

        List<LikingModelBeans> lstLiking = new ArrayList<LikingModelBeans>();

        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select * from Liking_Models where Liking_Model_Status = 1 and Liking_Id= " + likingCate;
        cnn = MyConnection.openConnection();
        try {
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                LikingModelBeans bean = new LikingModelBeans();

                bean.setLiking_Id(rs.getInt("Liking_Model_Id"));
                bean.setLiking_Model_Name(rs.getString("Liking_Model_Name"));

                lstLiking.add(bean);

            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return lstLiking;

    }

    public static List<CountryBeans> selectAllCountries() {
        List<CountryBeans> list = new ArrayList<CountryBeans>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select * from Countries where Country_Status=1";
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                CountryBeans bean = new CountryBeans();
                bean.setCountry_Id(rs.getInt("Country_Id"));
                bean.setCountry_Name(rs.getString("Country_Name"));
                bean.setCountry_Status(rs.getInt("Country_Status"));
                list.add(bean);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static List<CityBeans> selectAllCitiesByCountry(int countryId) {
        List<CityBeans> list = new ArrayList<CityBeans>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select * from Cities where Country_Id=?";
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            stm.setInt(1, countryId);
            rs = stm.executeQuery();
            while (rs.next()) {
                CityBeans bean = new CityBeans();
                bean.setCity_Id(rs.getInt("City_Id"));
                bean.setCity_Name(rs.getString("City_Name"));
                bean.setCountry_Id(rs.getInt("Country_Id"));
                list.add(bean);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static List<CityBeans> selectAllCity() {
        List<CityBeans> list = new ArrayList<CityBeans>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select * from Cities";
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                CityBeans bean = new CityBeans();
                bean.setCity_Id(rs.getInt("City_Name"));
                bean.setCity_Name(rs.getString("City_Name"));
                list.add(bean);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static List<ReligionBeans> selectAllReligions() {
        List<ReligionBeans> list = new ArrayList<ReligionBeans>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select * from Religion_Types where Religion_Type_Status=1";
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                ReligionBeans bean = new ReligionBeans();
                bean.setReligion_Id(rs.getInt("Religion_Type_Id"));
                bean.setReligion_Name(rs.getString("Religion_Type_Name"));
                bean.setReligion_Status(rs.getInt("Religion_Type_Status"));
                list.add(bean);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static List<MotherTongueBeans> selectAllMotherTongues() {
        List<MotherTongueBeans> list = new ArrayList<MotherTongueBeans>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select * from MotherTongues";
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                MotherTongueBeans bean = new MotherTongueBeans();
                bean.setMother_Tongue_Id(rs.getInt("Mother_Tongue_Id"));
                bean.setMother_Tongue_Name(rs.getString("Mother_Tongue_Name"));
                bean.setMother_Tongue_Status(rs.getInt("Mother_Tongue_Status"));
                list.add(bean);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static List<ProfessionalBeans> selectAllProfessionals() {
        List<ProfessionalBeans> list = new ArrayList<ProfessionalBeans>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select * from Professional_Types where Professional_Status= 1";
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                ProfessionalBeans bean = new ProfessionalBeans();
                bean.setProfessional_Id(rs.getInt("Professinal_Id"));
                bean.setProfessional_Name(rs.getString("Professinal_Name"));
                bean.setProfessional_Status(rs.getInt("Professional_Status"));
                list.add(bean);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static List<CasteBeans> selectAllCaste() {
        List<CasteBeans> list = new ArrayList<CasteBeans>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select * from Castes where Caste_Status=1";
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                CasteBeans bean = new CasteBeans();
                bean.setCaste_Id(rs.getInt("Caste_Id"));
                bean.setCaste_Name(rs.getString("Caste_Name"));
                bean.setCaste_Status(rs.getInt("Caste_Status"));
                list.add(bean);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static List<LikingCateBeans> selectAllLikingCaste() {
        List<LikingCateBeans> list = new ArrayList<LikingCateBeans>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        int likingStatus = 0;
        String sql = Inserts.sqlSelectComm("Liking_Cates") + "WHERE Liking_Status =1";
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                LikingCateBeans bean = new LikingCateBeans();

                bean.setLiking_Id(rs.getInt("Liking_Id"));
                bean.setLiking_Name(rs.getString("Liking_Name"));
                bean.setLiking_Status(rs.getInt("Liking_Status"));
                list.add(bean);

            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }
     public static List<LikingModelBeans> selectAllLikingModels() {
        List<LikingModelBeans> list = new ArrayList<LikingModelBeans>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        int likingStatus = 0;
        String sql = Inserts.sqlSelectComm("Liking_Models") ;
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                LikingModelBeans bean = new LikingModelBeans();

                bean.setLiking_Model_Name(rs.getString("Liking_Model_Name"));
                bean.setLiking__Model_Id(rs.getInt("Liking_Model_Id"));
                list.add(bean);

            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static List<LikingModelBeans> selectLikingModelsbyLiking(int likingid) {
        List<LikingModelBeans> list = new ArrayList<LikingModelBeans>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        int likingModelStatus = 0;

        String sql = Inserts.sqlSelectComm("Liking_Models") + " Where Liking_Id = " + likingid;
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                LikingModelBeans bean = new LikingModelBeans();
                likingModelStatus = rs.getInt("Liking_Model_Id");
                if (likingModelStatus != 0) {
                    bean.setLiking__Model_Id(rs.getInt("Liking_Model_Id"));
                    bean.setLiking_Model_Name(rs.getString("Liking_Model_Name"));
                    bean.setLiking_Id(rs.getInt("Liking_Id"));
                    list.add(bean);
                }
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

//------------------------------------------                              -------------------------------------------
    public static List<AccountBasicBean> selectAccountBasicByUsername(String username) {
        List<AccountBasicBean> list = new ArrayList<AccountBasicBean>();
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;

        String sql = Inserts.sqlSelectComm("Accounts") + " Where User_Name = '" + username + "'";
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {

                AccountBasicBean bean = new AccountBasicBean();
                bean.setUser_Name(rs.getString("User_Name"));
                bean.setUser_Email(rs.getString("User_Email"));
                bean.setDate_register(rs.getString("Date_Registed"));
                bean.setDate_Exprired(rs.getString("Date_Expired"));
                bean.setGender(rs.getString("Gender"));
                list.add(bean);

            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static List<AccountDetailBeans> selectDetailAccountByUsername(String username) {
        List<AccountDetailBeans> list = new ArrayList<AccountDetailBeans>();

        int accountID = getDetailAccountIDbyUsername(username);
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;

        String sql = "Select * From Account_Details Where Account_Details_Id = " + accountID;
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {

                AccountDetailBeans bean = new AccountDetailBeans();
                bean.setFull_Name(rs.getString("Full_Name"));
                bean.setDateOfBirth(rs.getString("Date_Of_Birth"));
                bean.setMarital_Status(rs.getString("Marital_Status"));
                bean.setMother_Tongue(rs.getString("Mother_Tongue"));
                bean.setHeight(rs.getInt("Height"));
                bean.setContact_Number(rs.getString("Contact_Number"));
                bean.setCaste_Id(rs.getInt("Caste_Id"));
                bean.setAddress(rs.getString("Address"));
                list.add(bean);

            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static int getAccountIdByAccountName(String username) {
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select Account_Id from Accounts where Account_Status=1 and User_Name=?";
        int accountId = 0;
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            stm.setString(1, username);
            rs = stm.executeQuery();
            if (rs.next()) {
                accountId = rs.getInt(1);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return accountId;
    }

    public static String getDateFromAccount(int accountId) {
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select Date_Expired from Accounts where Account_Status=1 and Account_Id=?";
        String date = "";
        try {
            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            stm.setInt(1, accountId);
            rs = stm.executeQuery();
            if (rs.next()) {
                date = rs.getString(1);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return date;
    }

    public static List<RequestBeans> getAllRequest() {
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select * from Requests";
        List<RequestBeans> list = new ArrayList<RequestBeans>();
        try {

            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                RequestBeans bean = new RequestBeans();
                bean.setAccount_Id(rs.getInt("Account_Id"));
                bean.setRequest_Sender_Id(rs.getInt("Request_Sender_Id"));
                bean.setRequest_Text(rs.getString("Request_Text"));
                bean.setRequest_Time(rs.getString("Request_Time"));
                list.add(bean);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return list;
    }

    public static String getAllRequestSenderNameById(int senderId) {
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "Select User_Name from Accounts where Account_Id=? ";
        String senderName = "";
        try {

            cnn = MyConnection.openConnection();
            stm = cnn.prepareCall(sql);
            stm.setInt(1, senderId);
            rs = stm.executeQuery();
            if (rs.next()) {
                senderName = rs.getString(1);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }
        return senderName;
    }

    //   GET Liking Model by Username
    public static List<LikingModelBeans> getLikingModelByUsername(String username) {

        List<LikingModelBeans> likingCaste = new ArrayList<LikingModelBeans>();

        int detailAcc = selects.getDetailAccountIDbyUsername(username);
        String[] columnName = {"Account_Details_Id", "Liking_Model_Id"};
        String[] tableName = {"Account_Details", "Liking_Details", "Liking_Models"};
        String sql = selects.sqlSelect(columnName, tableName) + "  WHERE Account_Details.Account_Details_Id = " + detailAcc;

        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;

        try {
            cnn = MyConnection.connType4();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                LikingModelBeans bean = new LikingModelBeans();
                bean.setLiking_Model_Name(rs.getString("Liking_Model_Name"));
                bean.setLiking__Model_Id(rs.getInt("Liking_Model_ID"));
                likingCaste.add(bean);
            }
        } catch (SQLException ex) {
            Logger.getLogger(selects.class.getName()).log(Level.SEVERE, null, ex);
        }


        return likingCaste;
    }
    // --------------------------Get Caste by Username

    public static List<CasteBeans> getCasteByUsername(String username) {

        List<CasteBeans> lstCaste = new ArrayList<CasteBeans>();

        int detailAcc = selects.getDetailAccountIDbyUsername(username);
        String sql = "Select * from Account_Details join Castes on Account_Details.Caste_Id = Castes.Caste_Id";
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;

        try {
            cnn = MyConnection.connType4();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                CasteBeans bean = new CasteBeans();
                bean.setCaste_Name(rs.getString("Caste_Name"));
                bean.setCaste_Id(rs.getInt("Caste_Id"));
                lstCaste.add(bean);
            }
        } catch (SQLException ex) {
            Logger.getLogger(selects.class.getName()).log(Level.SEVERE, null, ex);
        }


        return lstCaste;
    }
// --------------------------Get City by Username

    public static List<CityBeans> getCityByUsername(String username) {
        List<CityBeans> list = new ArrayList<CityBeans>();
        int detailAcc = selects.getDetailAccountIDbyUsername(username);
        String[] columnName = {"Account_Details_Id", "City_Id"};
        String[] tableName = {"Account_Details", "Expension", "Cities"};
        String sql = selects.sqlSelect(columnName, tableName) + " WHERE Account_Details.Account_Details_Id = " + detailAcc;

        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;

        try {
            cnn = MyConnection.connType4();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                CityBeans bean = new CityBeans();
                bean.setCity_Id(rs.getInt("City_Id"));
                bean.setCity_Name(rs.getString("City_Name"));

                list.add(bean);
            }
        } catch (SQLException ex) {
            Logger.getLogger(selects.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }


        return list;
    }

// --------------------------Get Religion by Username
    public static List<ReligionBeans> getReligionByUsername(String username) {
        List<ReligionBeans> lst = new ArrayList<ReligionBeans>();

        int detailAcc = selects.getDetailAccountIDbyUsername(username);
        String[] columnName = {"Account_Details_Id", "Religion_Type_ID"};
        String[] tableName = {"Account_Details", "Religion_Details", "Religion_Types"};
        String sql = selects.sqlSelect(columnName, tableName) + " WHERE Account_Details.Account_Details_Id = " + detailAcc;

        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;

        try {
            cnn = MyConnection.connType4();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                ReligionBeans bean = new ReligionBeans();
                bean.setReligion_Name(rs.getString("Religion_Type_Name"));
                bean.setReligion_Id(rs.getInt("Religion_Type_ID"));
                lst.add(bean);
            }
        } catch (SQLException ex) {
            Logger.getLogger(selects.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }


        return lst;
    }

    // GET CountryID by Username
    public static int getCountryIDByUsername(String username) {
        int detailAcc = selects.getDetailAccountIDbyUsername(username);
        String[] columnName = {"Account_Details_Id", "City_Id"};
        String[] tableName = {"Account_Details", "Expension", "Cities"};
        String sql = selects.sqlSelect(columnName, tableName) + " WHERE Account_Details.Account_Details_Id = " + detailAcc;
        int countryID = 0;
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;

        try {
            cnn = MyConnection.connType4();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                countryID = rs.getInt("Country_Id");
            }
        } catch (SQLException ex) {
            Logger.getLogger(selects.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }


        return countryID;
    }

// --------------------------Get Profession by Username
    public static List<ProfessionalBeans> getProfessionalByUsername(String username) {
        List<ProfessionalBeans> lst = new ArrayList<ProfessionalBeans>();
        int detailAcc = selects.getDetailAccountIDbyUsername(username);
        String[] columnName = {"Account_Details_Id", "Professional_Id"};
        String[] tableName = {"Account_Details", "Professional_Details", "Professional_Types"};
        String sql = selects.sqlSelect(columnName, tableName) + " WHERE Account_Details.Account_Details_Id = " + detailAcc;

        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;

        try {
            cnn = MyConnection.connType4();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                ProfessionalBeans bean = new ProfessionalBeans();
                bean.setProfessional_Name(rs.getString("Professinal_Name"));
                bean.setProfessional_Id(rs.getInt("Professional_ID"));
                lst.add(bean);
            }
        } catch (SQLException ex) {
            Logger.getLogger(selects.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }


        return lst;
    }
// --------------------------Get DetailAccount by Username

    public static List<LikingModelBeans> getLikingNotMatchByUsername(String username, int likingId) {

        List<LikingModelBeans> likingList5 = new ArrayList<LikingModelBeans>();
        likingList5 = selects.selectLikingModelsbyLiking(likingId); // lay ra tat ca
        List<LikingModelBeans> likingList2 = new ArrayList<LikingModelBeans>();
        likingList2 = selects.getLikingModelByUsername("Yoko5");// lay ra theo member

        for (int n = 0; n < likingList5.size(); n++) {
            for (int m = 0; m < likingList2.size(); m++) {
                if (likingList5.get(n).getLiking__Model_Id() == likingList2.get(m).getLiking__Model_Id()) {
                    likingList5.remove(n);

                }
            }

        }
        return likingList5;
    }

    public static int getDetailAccountIDbyUsername(String username) {

        int detailAccountID = 0;
        String email = "";
        Connection cnn = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "SELECT * FROM Accounts join Account_Details ";
        sql += "on Account_Details.Account_Id = Accounts.Account_Id where Accounts.User_Name='" + username + "'";
        System.out.println("sql: " + sql);

        try {
            cnn = MyConnection.connType4();
            stm = cnn.prepareCall(sql);
            rs = stm.executeQuery();
            while (rs.next()) {
                detailAccountID = rs.getInt("Account_Details_Id");
                email = rs.getString("Full_Name");
            }
        } catch (SQLException ex) {
            Logger.getLogger(selects.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            MyConnection.closeConnection(cnn, stm, rs);
        }


        return detailAccountID;
    }

    // Cau lenh Select voi 3 bang
    public static String sqlSelect(String[] columnName, String[] tableName) {

        String sql = "Select * FROM ";
//       columnName = {"Account_Details_Id", "Religion_Type_Name"};
//       tableName = {"Account_Details", "Religion_Details", "Religion_Types"};

        for (int k = 0; k <= tableName.length; k++) {
            for (int j = 0; j < columnName.length; j++) {
                //sql += tableName[k] + "." + columnName[j] + " ," + tableName[k + 2] + "." + columnName[j + 1] + " FROM ";
                sql += tableName[k] + " JOIN " + tableName[k + 1] + " ON ";
                sql += tableName[k] + "." + columnName[j] + " = " + tableName[k + 1] + "." + columnName[j];
                sql += " JOIN " + tableName[k + 2] + " ON " + tableName[k + 2] + "." + columnName[j + 1] + " = " + tableName[k + 1] + "." + columnName[j + 1];
                break;
            }

            break;
        }

        System.out.println(sql);
        return sql;
    }

    public static void main(String[] args) {

        List<LikingModelBeans> likingList5 = new ArrayList<LikingModelBeans>();
        likingList5 = selects.selectAllLikingModels();
        List<LikingModelBeans> likingList2 = new ArrayList<LikingModelBeans>();
        likingList2 = selects.getLikingModelByUsername("LanLan");// lay ra theo member

        for (int i = 0; i < likingList5.size(); i++) {
           if(likingList5.containsAll(likingList2)){
           
           }      
        }
        
//      
//        List<LikingModelBeans> temp = new ArrayList<LikingModelBeans>(likingList5);
//            likingList5.removeAll(likingList2);
//        for (int i = 0; i < likingList5.size(); i++) {
//            System.out.println("- "+likingList5.get(i).getLiking__Model_Id());
//            
//        }


        
        
    }
}
